<template>
    <div class="login">
        <div class="login-from">
            <el-input placeholder="请输入内容" v-model="username">
                <i slot="prefix" class="el-input__icon el-icon-user-solid"></i>
            </el-input>
            <el-input placeholder="请输入内容" v-model="password">
                <i slot="prefix" class="el-input__icon el-icon-s-tools"></i>
            </el-input>
            <el-button type="primary" @click="loginHandel">登录</el-button>
        </div>
    </div>
</template>
<script>
// import { getLoginApi } from '@/utlis/api/login/loginapi';
export default {
    data() {
        return {
            username: 'admin',
            password: '123456'
        }
    },
    methods: {
        loginHandel() {
            // getLoginApi({ username: this.username, password: this.password }).then((res) => {
            //     if (res.data.meta.status === 200) {
            //         this.$message({
            //             message: res.data.meta.msg,
            //             type: 'success'
            //         });
            // localStorage.setItem('token', res.data.data.token)
            // location.href = '/'
            this.$store.dispatch('setLogin',
                { username: this.username, password: this.password }).then((res) => {
                    localStorage.setItem('token', res.data.data.token)
                    location.href = '/'
                })
            // } else {
            //     this.$message({
            //         message: res.data.meta.msg,
            //         type: 'error'
            //     });
            // }
            // })
        }
    }
}
</script>
<style lang="scss" scoped>
.login-from {
    width: 600px;
    height: 300px;
    position: absolute;
    left: 50%;
    top: 30%;
    margin-left: -300px;
    border: 5px solid green;
    padding: 40px 20px;

    .el-input {
        margin: 20px 0;
    }

    .el-button {
        width: 100%;
    }
}
</style>